Shader "geometry/geoLine"
{
    Properties
    {
        _BaseColor("Base Color", Color) = (0, 1, 0, 0.5)
        _ExtrusionFactor("Extrusion factor", Range(0,10)) = 1
    }
    SubShader
    {
        Tags { "RenderType"="Opaque" }
        Blend SrcAlpha One
        LOD 100

        Pass
        {
            CGPROGRAM
            #pragma vertex vert
            #pragma geometry geom
            #pragma fragment frag

            #include "UnityCG.cginc"

            struct appdata
            {
                float4 vertex : POSITION;
                float4 normal : NORMAL;
            };

            struct v2g
            {
                float4 vertex : SV_POSITION;
                float4 color : COLOR;
            };

            struct g2f 
            { 
                float2 uv : TEXCOORD0; 
                float4 vertex : SV_POSITION; 
            }; 

            sampler2D _MainTex;
            float4 _MainTex_ST;
            fixed4 _BaseColor;
            float _ExtrusionFactor;

            v2g vert (appdata v)
            {
                v2g o;
                float offset = abs(frac(_Time.y)-0.5) * _ExtrusionFactor;//_ExtrusionFactor;//
                v.vertex.xyz += normalize(v.normal) * offset;
                o.vertex = UnityObjectToClipPos(v.vertex);
                UNITY_TRANSFER_FOG(o,o.vertex);
                return o;
            }

            [maxvertexcount(3)] 
            void geom(triangle v2g input[3],inout LineStream<g2f> outStream){ 
                g2f o=(g2f)0; 

                for(int i=1;i<3;i++){
                    o.vertex = input[i].vertex; 
                    outStream.Append(o); 
                }
            } 

            fixed4 frag (g2f i) : SV_Target
            {
                return _BaseColor;
            }
            ENDCG
        }
    }
}
